package com.yian.houseproperty.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yian.houseproperty.entity.Houseinfo;
import com.yian.houseproperty.service.IHouseinfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yian
 * @since 2022-03-14
 */
@RestController
@RequestMapping("/houseinfo")
public class HouseinfoController {
    @Resource
    private IHouseinfoService houseinfoService;
    @GetMapping("/selectAll")
    public List<Houseinfo> selectAll(){

        return houseinfoService.list();
    }
    @GetMapping("/selectByUid/{uid}")
    public List<Houseinfo> selectByUid(@PathVariable Integer uid){
        QueryWrapper<Houseinfo> wrapper=new QueryWrapper<>();
        wrapper.eq("uid",uid);
        return houseinfoService.list(wrapper);
    }
    @GetMapping("/sell/{hid}")
    public void sell(@PathVariable Integer hid){
        Houseinfo houseinfo=new Houseinfo();
        houseinfo.setIsSold(1);
        houseinfo.setHid(hid);
        houseinfoService.updateById(houseinfo);
    }

}

